home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 49 / Amiga Format CD49 (2000-01-17)(Future Publishing)(GB)(Track 1 of 3)[!][issue 2000-02].iso / -serious- / graphics / amicad / arexx / chargerc.amicad < prev    next >
Text File  |  1999-12-06  |  4KB  |  158 lines

  1. /* Tracé de la courbe de charge d'un condensateur.
  2. $VER: 1.00 (© R.Florac, 12 Novembre 1998) */
  3.  
  4. options results     /* indispensable pour récupérer le résultat des macros */
  5.  
  6. signal on error     /* pour l'interception des erreurs */
  7. signal on syntax
  8.  
  9. clip=-1
  10. FIRSTSEL; obj=result
  11. if obj>0 then do
  12.     'TYPE(FIRSTSEL)'; type=result
  13.     if type=22 then do
  14.     'CLIPUNIT(5)'; clip=result
  15.     'COORDS(FIRSTSEL)'; coords=result
  16.     PARSE VAR coords x0 ',' y0 ',' x1 ',' y1
  17.     xg=minima(x0,x1); xd=maxima(x0,x1)
  18.     yh=minima(y0,y1); yb=maxima(y0,y1)
  19.     l=xd-xg+1; h=yb-yh+1
  20.     'NEXTSEL('obj')'; obj=result
  21.     end
  22. end
  23. else obj=1
  24.  
  25. if obj>0 then do
  26.     'MESSAGE("Dessinez et sélectionnez"+CHR(10)+"un rectangle dans"+CHR(10)+"lequel doit être"+CHR(10)+"intégrée la grille")'
  27.     call quitter
  28. end
  29.  
  30. ndh=5
  31. y1=yh+h
  32. x1=xg+ndh*(l%ndh)
  33. 'SAVEALL(-1)'
  34.  
  35. 'DELETE(FIRSTSEL):ROTATE(0,0)'
  36. /* Tracé des lignes verticales */
  37. do i=1 to 5
  38.     x2 = xg+i*(l/ndh)
  39.     x2 = x2%1
  40.     'DRAWMODE(1)'
  41.     do c=1 to 9
  42.     xc = x2-(l/ndh)/10*c
  43.     xc=xc%1
  44.     'DRAW('xc','yh','xc','yb')'
  45.     end
  46.     'DRAWMODE(2):DRAW('x2','yh','x2','yb')'
  47. end
  48. /* Repères verticaux */
  49. if h>300 then hc=2
  50. else hc=1
  51. if l>600 then lc=2
  52. else lc=1
  53. 'SETSCALE(0,'lc'*100,'hc'*100)'
  54. if lc=1 then lc=8
  55. else lc=16
  56. if hc=1 then hc=8
  57. else hc=16
  58.  
  59. if xg-5*lc<0 then do
  60.     'MESSAGE("Position grille incorrecte"+CHR(10)+"(Trop à gauche)")'
  61.     call quitter
  62. end
  63.  
  64. 'DRAWMODE(1):WRITE("0",'xg-lc-lc','yb+hc/2')'
  65. p=h%4
  66. 'WRITE("0,25",'xg-4*lc-lc','yh+3*p+hc/2')'
  67. 'WRITE("0,5",'xg-3*lc-lc','yh+2*p+hc/2')'
  68. 'WRITE("0,75",'xg-4*lc-lc','yh+p+hc/2')'
  69. 'WRITE("1",'xg-lc-lc','yh+hc/2')'
  70. /* Tracé des lignes horizontales */
  71. ndv=2
  72. do i=1 to ndv
  73.     y2 = yh+(i-1)*(h/ndv)
  74.     y2=y2%1
  75.     'DRAWMODE(2):DRAW('xg','y2','xd','y2')'
  76.     y2 = (yh)+i*(h/ndv)
  77.     y2 = y2%1
  78.     'DRAWMODE(1)'
  79.     do c=1 to 9
  80.     yc = y2-(h/ndv)/10*c
  81.     yc=yc%1
  82.     'DRAW('xg','yc','xd','yc')'
  83.     end
  84. end
  85. /* Repères horizontaux */
  86. n=0.5
  87. p=(l/10)%1
  88. ndv=yb+hc+hc/2
  89. 'WRITE("0",'xg-lc/2','ndv')'
  90. 'WRITE("0,5",'xg+p-lc','ndv')'
  91. 'WRITE("1RC",'xg+2*p-2*lc+lc/2','ndv')'
  92. 'WRITE("1,5",'xg+3*p-2*lc+lc/2','ndv')'
  93. 'WRITE("2RC",'xg+4*p-2*lc+lc/2','ndv')'
  94. 'WRITE("2,5",'xg+5*p-2*lc+lc/2','ndv')'
  95. 'WRITE("3RC",'xg+6*p-2*lc+lc/2','ndv')'
  96. 'WRITE("3,5",'xg+7*p-2*lc+lc/2','ndv')'
  97. 'WRITE("4RC",'xg+8*p-2*lc+lc/2','ndv')'
  98. 'WRITE("4,5",'xg+9*p-2*lc+lc/2','ndv')'
  99. 'WRITE("5RC",'xg+10*p-2*lc+lc/2','ndv')'
  100.  
  101. /* Tracé des axes */
  102. 'WRITE("U",'xg-lc*2','yh-hc')'
  103. 'WRITE("t",'xd+3*lc','ndv')'
  104. 'DRAWMODE(2):DRAW('xg','yb','xg','yh-hc'):DRAW('xg','yb','xd+2*lc','yb')'
  105. 'SETSCALE(0,100,100):CONVERT(PUTPART("Flèche",'xg-10','yh-hc-20'),1)'
  106. 'ROTATE(0,1):CONVERT(PUTPART("Flèche",'xd+2*lc','yb-10'),1):DRAWMODE(3)'
  107.  
  108. /* Tracé de la courbe de charge */
  109. if ~show('L','rexxmathlib.library') then
  110.     call addlib('rexxmathlib.library',0,-30)
  111. tau=l/5
  112. y0=yb; x0=xg
  113. do i=1 to l/5
  114.     y=h+(-h*exp(-5*i/tau))
  115.     y=y%1
  116.     'DRAW('x0','y0','x0+5','yb-y')'
  117.     x0=x0+5
  118.     y0=yb-y
  119. end
  120.  
  121. /* Tracé de la courbe de charge */
  122. y0=yh; x0=xg
  123. do i=1 to l/5
  124.     y=h+(-h*exp(-5*i/tau))
  125.     y=y%1
  126.     'DRAW('x0','y0','x0+5','yh+y')'
  127.     x0=x0+5
  128.     y0=yh+y
  129. end
  130.  
  131. call quitter
  132.  
  133. minima: procedure
  134.     parse arg v1,v2
  135.     if v1<v2 then return v1
  136.     return v2
  137. end
  138.  
  139. maxima: procedure
  140.     parse arg v1,v2
  141.     if v1>v2 then return v1
  142.     return v2
  143. end
  144.  
  145. quitter: procedure expose clip
  146.     if clip>=0 then 'CLIPUNIT('clip')'
  147.     exit
  148.  
  149. /* Traitement des erreurs, interruption du programme */
  150. syntax:
  151. erreur=RC
  152. 'MESSAGE("Erreur de syntaxe"+CHR(10)+"en ligne 'SIGL'"+CHR(10)+"'errortext(erreur)'")'
  153. exit
  154.  
  155. error:
  156. 'MESSAGE("Erreur en ligne 'SIGL'")'
  157. exit
  158.